﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common.Logging;
using WuDada.Core.Member;
using WuDada.Core.Member.Service;
using WuDada.Core.Member.Domain;
using WuDada.Core.Generic.Util;

public partial class join : System.Web.UI.Page
{
    private ILog m_Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    private MemberFactory m_MemberFactory;
    private IMemberService m_MemberService;
    private HttpHelper m_HttpHelper;
    private WebMailService m_WebMailService;

    protected void Page_Load(object sender, EventArgs e)
    {
        m_MemberFactory = new MemberFactory();
        m_MemberService = m_MemberFactory.GetMemberService();
        m_HttpHelper = new HttpHelper();
        m_WebMailService = new WebMailService();

        if (!IsPostBack)
        {
            int id = QueryStringHelper.GetInteger("id", 0);
            string token = QueryStringHelper.GetString("token");
            string msg = "會員認證失敗";

            MemberVO memberVO = m_MemberService.GetMemberById(id);
            if (memberVO != null)
            {
                if (memberVO.Token.Equals(token))
                {
                    memberVO.UserConfirm = "1";
                    memberVO.UpdatedDate = DateTime.Now;
                    m_MemberService.UpdateMember(memberVO);
                    msg = "會員認證成功";
                }
            }

            ltlMsg.Text = msg;
        }
    }    
}